/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

import QtQuick 2.0
import QtQml 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5
import QtQml.Models 2.2
import org.ukui.qqc2style.private 1.0 as StylePrivate

Rectangle {
    id: rectRoot

    property string infoBoxImageSource
    property string infoBoxText
    property string  cancelBtnText
    property string  confirmBtnText
    property string desktopFile
    property var visualIndex
    property var pageIndex
    property var groupId

    color: StylePrivate.StyleHelper.windowcolorrole
    visible: false; radius: Style.tabletScaleFactor * 22
    width: Style.tabletScaleFactor * 520; height: Style.tabletScaleFactor * 220
    anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter
    ColumnLayout {
        spacing: 0
        anchors.fill: parent; Layout.alignment: Qt.AlignCenter
        Layout.fillHeight: true; Layout.fillWidth: true
        RowLayout {
            width: Style.tabletScaleFactor * 400; height: Style.tabletScaleFactor * 64
            spacing: Style.tabletScaleFactor * 16; Layout.leftMargin: Style.tabletScaleFactor * 40
            Layout.topMargin: Style.tabletScaleFactor * 20
            Image {
                id: infoBoxImage
                Layout.maximumHeight: Style.tabletScaleFactor *64
                Layout.maximumWidth: Style.tabletScaleFactor *64
                sourceSize: Qt.size(Style.tabletScaleFactor *64, Style.tabletScaleFactor *64)
                source: infoBoxImageSource
            }
            Text {
                text: "确认卸载" + infoBoxText + "应用？"
                width: Style.tabletScaleFactor * 154; height: Style.tabletScaleFactor * 25
                font.pointSize: 13; color: "#262626";
                font.family: StylePrivate.StyleHelper.font.family
                font.styleName: StylePrivate.StyleHelper.font.styleName
                Layout.alignment: Qt.AlignCenter
            }
        }
        RowLayout {
            width: Style.tabletScaleFactor * 272; height: Style.tabletScaleFactor * 46
            spacing: Style.tabletScaleFactor * 20; Layout.leftMargin: Style.tabletScaleFactor * 255
            Layout.bottomMargin: Style.tabletScaleFactor * 15
            Button {
                id: cancelBtn
                width: Style.tabletScaleFactor * 126; height: Style.tabletScaleFactor * 46
                StylePrivate.StyleHelper.buttonType:"MinButton"
                text: cancelBtnText
                onClicked: {
                    console.log("===取消卸载===")
                    rectRoot.visible = false
                }
            }
            Button {
                id: confirmBtn
                width: Style.tabletScaleFactor * 126; height: Style.tabletScaleFactor * 46
                StylePrivate.StyleHelper.buttonType:"blueButton"
                text: confirmBtnText
                onClicked: {
                    console.log("===确认卸载===")
                    rectRoot.visible = false
                    modelManager.uninsatllApp(desktopFile)
                }
            }
        }
    }
}
